<%--
  Created by IntelliJ IDEA.
  User: 86175
  Date: 2023/5/28
  Time: 22:22
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.6.2/css/bootstrap.min.css">
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <script>
        function addRow() {
            var table = document.getElementById("courseTable");
            var row = table.insertRow();
            var cell1 = row.insertCell(0);
            var cell2 = row.insertCell(1);
            var cell3 = row.insertCell(2);
            var cell4 = row.insertCell(3);
            var cell5 = row.insertCell(4);
            cell1.innerHTML = "<input type=\"text\" name=\"columnName\" class=\"form-control\">";
            cell2.innerHTML = "<div class=\"form-group\">\n" +
                "                    <select class=\"form-control\" id=\"exampleFormControlSelect1\" name=\"dataType\">\n" +
                "                        <option value=\"int\" selected>int</option>\n" +
                "                        <option value=\"varchar\">varchar</option>\n" +
                "                        <option value=\"float\">float</option>\n" +
                "                        <option value=\"double\">double</option>\n" +
                "                        <option value=\"char\">char</option>\n" +
                "                    </select>\n" +
                "                </div>";
            cell3.innerHTML = "<input type=\"number\" name=\"length\" value=\"255\" class=\"form-control\">";
            cell4.innerHTML = "                <div class=\"form-group\">\n" +
                "                    <select class=\"form-control\" name=\"isNull\">\n" +
                "                        <option value=\"NOT NULL\">否</option>\n" +
                "                        <option value=\"NULL\" selected>是</option>\n" +
                "                    </select>\n" +
                "                </div>";
            cell5.innerHTML = "                <div class=\"form-group\">\n" +
                "                    <select class=\"form-control\" name=\"Primarykey\">\n" +
                "                        <option value=\"not\" selected>否</option>\n" +
                "                        <option value=\"is\" >是</option>\n" +
                "                    </select>\n" +
                "                </div>";
        }
    </script>
</head>
<body>
<form class="table" action="addTableServlet" method="post">
    <div style="float: right">
        <input type="text" name="tableName" placeholder="文本框" class="layui-input">
        <button type="button" class="btn btn-primary" onclick="addRow()">添加栏位</button>
        <input type="submit" class="btn btn-success" value="提交">
    </div>
    <table class="layui-table" style="width: 80%;margin: auto">
        <thead>
        <tr>
            <th>列名</th>
            <th>数据类型</th>
            <th>长度</th>
            <th>为空</th>
            <th>主键</th>
        </tr>
        </thead>
        <tbody id="courseTable">
        <tr>
            <td>
                <input type="text" name="columnName" class="form-control">
            </td>
            <td>
                <div class="form-group">
                    <select class="form-control" id="exampleFormControlSelect1" name="dataType">
                        <option value="int" selected>int</option>
                        <option value="varchar">varchar</option>
                        <option value="float">float</option>
                        <option value="double">double</option>
                        <option value="char">char</option>
                    </select>
                </div>
            </td>
            <td>
                <input type="number" name="length" value="255" class="form-control">
            </td>
            <td>
                <div class="form-group">
                    <select class="form-control" name="isNull">
                        <option value="NOT NULL">否</option>
                        <option value="NULL" selected>是</option>
                    </select>
                </div>
            </td>
            <td>
                <div class="form-group">
                    <select class="form-control" name="Primarykey">
                        <option value="not" selected>否</option>
                        <option value="is">是</option>
                    </select>
                </div>
            </td>
        </tr>
        </tbody>
    </table>
</form>
</body>
</html>
